package com.example.androidmainshixun.view;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.androidmainshixun.R;

public class Publishprocurement extends AppCompatActivity {
    private ImageView mImage;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.publish_procurement);
        mImage=findViewById(R.id.image1);

        // 获取 Spinner 实例
        Spinner spinnerGoodsType = findViewById(R.id.style2);
        Spinner spinnerSourceLocation = findViewById(R.id.source_location_spinner);
        Spinner spinnerPurchaseCycle = findViewById(R.id.purchase_cycle_spinner);
        Spinner spinnerRegion = findViewById(R.id.style1); // 假设 style1 是收货地区的 Spinner ID


        // 设置 Spinner 的适配器
        @SuppressLint("ResourceType")
        ArrayAdapter<String> adapterGoodsType = new ArrayAdapter<>(this,
                android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.goods_types));
        spinnerGoodsType.setAdapter(adapterGoodsType);
        @SuppressLint("ResourceType")
        ArrayAdapter<String> adapterSourceLocation = new ArrayAdapter<>(this,
                android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.source_locations));
        spinnerSourceLocation.setAdapter(adapterSourceLocation);
        @SuppressLint("ResourceType")
        ArrayAdapter<String> adapterPurchaseCycle = new ArrayAdapter<>(this,
                android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.purchase_cycles));
        spinnerPurchaseCycle.setAdapter(adapterPurchaseCycle);
        @SuppressLint("ResourceType")
        ArrayAdapter<String> adapterRegion = new ArrayAdapter<>(this,
                android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.regions));
        spinnerRegion.setAdapter(adapterRegion);


        // 设置下拉时的布局样式
        adapterGoodsType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        adapterSourceLocation.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        adapterPurchaseCycle.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        adapterRegion.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);





        mImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

}
